/* 
 *  Copyright (C) 2007 Dip. Ing. dell'Informazione, University of Pisa, Italy
 *  http://info.iet.unipi.it/~cng/ns2voip/
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, USA
 */
/*
 */

#ifndef __NS2_VOIP_DECODER_STATIC_H
#define __NS2_VOIP_DECODER_STATIC_H

#include <voip_decoder.h>

#include <t_timers.h>
#include <queue>


class VoipDecoderStatic : public VoipDecoder {
public:
        //! Create an empty VoIP decoder.
        VoipDecoderStatic ();

        //! Tcl interface.
        int command (int argc, const char*const* argv);

        //! Periodic playout timer
        void handle();

protected:
        //! Collect statistics after playout buffering frame by frame.
        void collectFrame (VoipFrame& frame);

protected:
        //! Frame buffer
        std::priority_queue< VoipFrame > buffer_;

        //! Next frame to be played out
        unsigned int nextFrame_;

        //! Length of the current talk (in frames)
        unsigned int talkLength_;

        //! Playout sample rate (in ms)
        double playoutRate_;

        //! Playout initial delay
        /** Delay of the first sample of the talkspurt
         */
        double initialDelay_;

        //! Playout buffer size.
        /** It is expressed in terms of number of VoIP samples, not in
         *  number of IP Packets!
         */
        int bufferSize_;

        //! Current buffer occupancy
        int bufferOccupancy_;

        //! T_Timer
        /** The timer is used to manage playout samples
         */
        TTimer<VoipDecoderStatic> timer_;
};

#endif // __NS2_VOIP_DECODER_STATIC_H
